Skip to content

add translate text messages using system api#3215

Draft
mikovskii wants to merge 1 commit into
deltachat:mainfrom
mikovskii:on-device-translate
Draft

add translate text messages using system api#3215
mikovskii wants to merge 1 commit into
deltachat:mainfrom
mikovskii:on-device-translate

Conversation

@mikovskii

Copy link
Copy Markdown
Contributor

Add a text message translation using the Apple Translate API

Details
cropped-870x1680-Screen.Recording.2026-07-22.at.2.40.13.PM.mp4

@r10s

r10s commented Jul 23, 2026

Copy link
Copy Markdown
Member

cool function!

however, there is a high chance that this api is not working offline but also online and affects confidentiality therefore.

i did not find any proof that this is not the case, but even if it offline that today, it maybe differently tomorrow, with any iOS update.

otoh, ppl may use worse tools for translation ...

still, as delta chat is not social media, but meant for friends&family, there is a high chance that two ppl speak the same language, so the pr has comparable low effect anyways.

@r10s r10s added the discussion discussions usually go to support.delta.chat label Jul 23, 2026
@r10s
r10s marked this pull request as draft July 23, 2026 12:24
@mikovskii

mikovskii commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the feedback. I agree that confidentiality is the main concern here.

According to Apple’s documentation, translation is performed on-device after the required language models have been downloaded. I can also verify the behavior in airplane mode and add a clear note that the feature is only available when on-device translation is supported.

Of course, we cannot guarantee that Apple will never change the implementation in a future iOS release. However, the same applies to many system APIs. We can only rely on the documented behavior of the current API and avoid using the feature whenever the system cannot provide an on-device translation.

Regarding the usefulness, I agree that it may not be a core feature for every user. Still, it can be helpful in international groups, communities, and conversations between multilingual friends or family members. It also avoids users copying potentially sensitive messages into third-party translation services.

@mikovskii

Copy link
Copy Markdown
Contributor Author

Apple documents that TranslationSession uses on-device ML models. I can additionally restrict the feature to language pairs whose LanguageAvailability status is .installed, so message text is passed to the translation session only after the required local models are already present.

This gives us a clear practical offline guarantee for the current documented implementation, and it can be verified in airplane mode and with network monitoring.

A fully enforceable guarantee would require shipping and running our own translation model, which would have substantial app-size and maintenance costs.

@Amzd Amzd left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would really appreciate this feature, as even friends sometimes don't know how to say something in one language so use another, so translating in app would make this a lot quicker @r10s


@available(iOS 17.4, *)
private func presentTranslation(text: String) {
let host = UIHostingController(rootView: TranslationPresentationView(text: text) { [weak self] in

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explicitly add the onDismiss label here so it is more readable what this closure does.

}

@available(iOS 17.4, *)
private func presentTranslation(text: String) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this and the TranslationPresentationView to their own file eg Translation.swift

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

discussion discussions usually go to support.delta.chat

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants